<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" src="/oa/Public/js/jquery.js"></script>
<script type="text/javascript" src="/oa/Public/js/common.js"></script>
<link rel="stylesheet" type="text/css" href="/oa/Public/css/global.css" />
<link rel="stylesheet" type="text/css" href="/oa/Public/css/form.css" />
</head>
<body>
<div class="search">
<b><?php echo ($name); ?></b>
<div class="tools">
全选：<input type="checkbox" name="checkid" onclick="if(this.checked==true) { checkAll('id[]'); } else { clearAll('id[]'); }" >
<input type="button" value="批量删除" onclick="del()" class="button">
<input type="button" value="图片上传" onclick="upload()" class="button">
<input type="button" value="返回相册" onclick="location.href='/oa/index.php/Album/lists'" class="button"></div>
</div>
<div class="list" >
	<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="album_view" onclick="check(<?php echo ($vo["id"]); ?>)" id="<?php echo ($vo["id"]); ?>">
		<div class="image"><img src="<?php echo ($vo["path"]); ?>/small/<?php echo ($vo["new_name"]); ?>" /><input type="checkbox" name="id[]" class="checkbox_<?php echo ($vo["id"]); ?>" value="<?php echo ($vo["id"]); ?>" style="display: none" ></div>
	</div><?php endforeach; endif; else: echo "" ;endif; ?>
</div>
</body>
<script type="text/javascript">
$('img').error(function() {
	$(this).attr("src", "/oa/Public/images/pic-error.png");
});
var url = "/oa/index.php/Album/";
function upload(){
	window.location.href=url+"upload?id="+<?php echo ($id); ?>;
}
function check(id){
	if($(".checkbox_"+id).prop("checked")){
		$(".checkbox_"+id).attr("checked",false);
		$("#"+id).removeClass("checked");
		
	}else{
		$(".checkbox_"+id).attr("checked",true);
		$("#"+id).addClass("checked");
	}
}
function del(){
		var id = '';
		$("input[name='id[]']:checked").each(function(){
			if( $(this).prop("checked") ){
				id+=$(this).val()+',';
			}
		});
		if( id == ''){
			alert("请至少选择一张图片！");
			return false;
		}
		if(confirm("确定要删除照片么？")){
			$.get(url+"deletepic?type=<?php echo ($id); ?>&id="+id, function(result){
				location.reload();
			});
		}else{
			return false;
		}
}

function checkAll(name) { 
	var el = document.getElementsByTagName('input'); 
	var len = el.length; 
	for(var i=0; i<len; i++) { 
		if((el[i].type=="checkbox") && (el[i].name==name)) { 
			el[i].checked = true; 
		} 
	} 
	$(".album_view").each(function(){
		$(this).addClass("checked");
	});
} 
function clearAll(name) { 
	var el = document.getElementsByTagName('input'); 
	var len = el.length; 
	for(var i=0; i<len; i++) { 
		if((el[i].type=="checkbox") && (el[i].name==name)) { 
			el[i].checked = false; 
		} 
	} 
	$(".album_view").each(function(){
		$(this).removeClass("checked");
	});
} 
</script>
</html>